<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
	<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
	<meta name="apple-mobile-web-app-capable" content="yes"/>
	<title>Heading</title>

	<script type="text/javascript" src="../../deviceTheme.js"
		data-dojo-config="mblThemeFiles: ['base','TabBar','dojox/mobile/themes/common/domButtons.css']"></script>
	<script type="text/javascript" src="../../../../dojo/dojo.js" data-dojo-config="async: true, parseOnLoad: true"></script>

	<script type="text/javascript">
		var timeoutInterval = 300;
		var WIDGET_CLASSNAME1 = "mblDomButtonWhitePlus";
		var WIDGET_CLASSNAME2 = "mblToolBarButtonSelected";
		var WIDGET_LABEL1 = "XXXX";
		require([
			"dojo/dom-class", // dojo.hasClass
			"dojo/ready",
			"dijit/registry",
			"doh/runner",	//doh functions
			"dojox/mobile/tests/doh/TestHelper",
			"dojox/mobile/parser",
			"dojox/mobile",
			"dojox/mobile/compat",
			"dojox/mobile/TabBar"
		], function(domClass, ready, registry, runner, TestHelper){
			ready(function(){
				runner.register("dojox.mobile.test.doh.ToolBarButton", [
					{
						name: "ToolBarButton setter 1",
						timeout: 4000,
						runTest: function(){
							var d = new runner.Deferred();
							var demoWidget1 = registry.byId("btn1");
							var demoWidget2 = registry.byId("btn2");
							var demoWidget3 = registry.byId("btn3");
							demoWidget1.set("icon", WIDGET_CLASSNAME1);
							demoWidget2.set("icon", WIDGET_CLASSNAME1);
							demoWidget3.set("icon", WIDGET_CLASSNAME1);
							setTimeout(d.getTestCallback(function(){

								var demoWidget1 = registry.byId("btn1");
								var demoWidget2 = registry.byId("btn2");
								var demoWidget3 = registry.byId("btn3");
								runner.assertTrue(domClass.contains(demoWidget1.iconNode.childNodes[0], WIDGET_CLASSNAME1), WIDGET_CLASSNAME1 + " value=" + demoWidget1.iconNode.childNodes[0].className);
								runner.assertTrue(domClass.contains(demoWidget2.iconNode.childNodes[0], WIDGET_CLASSNAME1), WIDGET_CLASSNAME1 + " value=" + demoWidget2.iconNode.childNodes[0].className);
								runner.assertTrue(domClass.contains(demoWidget3.iconNode.childNodes[0], WIDGET_CLASSNAME1), WIDGET_CLASSNAME1 + " value=" + demoWidget3.iconNode.childNodes[0].className);

								demoWidget1.set("icon", "../images/tab-icon-33w.png");
								demoWidget2.set("icon", "../images/tab-icon-33w.png");
								demoWidget3.set("icon", "../images/tab-icon-33w.png");
							}), timeoutInterval);
							return d;
						}
					},
					{
						name: "ToolBarButton setter 2",
						timeout: 4000,
						runTest: function(){
							var d = new runner.Deferred();
							setTimeout(d.getTestCallback(function(){

								var demoWidget1 = registry.byId("btn1");
								var demoWidget2 = registry.byId("btn2");
								var demoWidget3 = registry.byId("btn3");
								TestHelper.verifyImageSrc(demoWidget1.iconNode.childNodes[0], /tab-icon-33w.png/i);
								TestHelper.verifyImageSrc(demoWidget2.iconNode.childNodes[0], /tab-icon-33w.png/i);
								TestHelper.verifyImageSrc(demoWidget3.iconNode.childNodes[0], /tab-icon-33w.png/i);

								demoWidget1.set("iconPos", "29,116,29,29");
								demoWidget1.set("icon", "../images/tab-icons.png");
								demoWidget2.set("iconPos", "29,116,29,29");
								demoWidget2.set("icon", "../images/tab-icons.png");
								demoWidget3.set("iconPos", "29,116,29,29");
								demoWidget3.set("icon", "../images/tab-icons.png");
							}), timeoutInterval);
							return d;
						}
					},
					{
						name: "ToolBarButton setter 3",
						timeout: 4000,
						runTest: function(){
							var d = new runner.Deferred();
							setTimeout(d.getTestCallback(function(){

								var demoWidget1 = registry.byId("btn1");
								var demoWidget2 = registry.byId("btn2");
								var demoWidget3 = registry.byId("btn3");
								TestHelper.verifyImageSrc(demoWidget1.iconNode.childNodes[0], /tab-icons.png/i);
								TestHelper.verifyImageSrc(demoWidget2.iconNode.childNodes[0], /tab-icons.png/i);
								TestHelper.verifyImageSrc(demoWidget3.iconNode.childNodes[0], /tab-icons.png/i);
								demoWidget1.set("selected", true);
								demoWidget2.set("selected", true);
								demoWidget3.set("selected", true);
							}), timeoutInterval);
							return d;
						}
					},
					{
						name: "ToolBarButton setter 4",
						timeout: 4000,
						runTest: function(){
							var d = new runner.Deferred();
							setTimeout(d.getTestCallback(function(){

								var demoWidget1 = registry.byId("btn1");
								var demoWidget2 = registry.byId("btn2");
								var demoWidget3 = registry.byId("btn3");
								runner.assertTrue(domClass.contains(demoWidget1.domNode, WIDGET_CLASSNAME2), WIDGET_CLASSNAME2 + " value=" + demoWidget1.iconNode.childNodes[0].className);
								runner.assertTrue(domClass.contains(demoWidget2.domNode, WIDGET_CLASSNAME2), WIDGET_CLASSNAME2 + " value=" + demoWidget2.iconNode.childNodes[0].className);
								runner.assertTrue(domClass.contains(demoWidget3.domNode, WIDGET_CLASSNAME2), WIDGET_CLASSNAME2 + " value=" + demoWidget3.iconNode.childNodes[0].className);
								runner.assertTrue(demoWidget1.get("selected"), 'return value of get("selected") should be true');
								runner.assertTrue(demoWidget2.get("selected"), 'return value of get("selected") should be true');
								runner.assertTrue(demoWidget3.get("selected"), 'return value of get("selected") should be true');
								demoWidget1.set("selected", false);
								demoWidget2.set("selected", false);
								demoWidget3.set("selected", false);
								demoWidget1.set("label", WIDGET_LABEL1);
								demoWidget2.set("label", WIDGET_LABEL1);
								demoWidget3.set("label", WIDGET_LABEL1);
							}), timeoutInterval);
							return d;
						}
					},
					{
						name: "ToolBarButton setter 5",
						timeout: 4000,
						runTest: function(){
							var d = new runner.Deferred();
							setTimeout(d.getTestCallback(function(){

								var demoWidget1 = registry.byId("btn1");
								var demoWidget2 = registry.byId("btn2");
								var demoWidget3 = registry.byId("btn3");
								runner.assertFalse(domClass.contains(demoWidget1.domNode, WIDGET_CLASSNAME2), WIDGET_CLASSNAME2 + " value=" + demoWidget1.iconNode.childNodes[0].className);
								runner.assertFalse(domClass.contains(demoWidget2.domNode, WIDGET_CLASSNAME2), WIDGET_CLASSNAME2 + " value=" + demoWidget2.iconNode.childNodes[0].className);
								runner.assertFalse(domClass.contains(demoWidget3.domNode, WIDGET_CLASSNAME2), WIDGET_CLASSNAME2 + " value=" + demoWidget3.iconNode.childNodes[0].className);
								runner.assertFalse(demoWidget1.get("selected"), 'return value of get("selected") should be false');
								runner.assertFalse(demoWidget2.get("selected"), 'return value of get("selected") should be false');
								runner.assertFalse(demoWidget3.get("selected"), 'return value of get("selected") should be false');
								runner.assertEqual(WIDGET_LABEL1, demoWidget1.labelNode.innerHTML);
								runner.assertEqual(WIDGET_LABEL1, demoWidget2.labelNode.innerHTML);
								runner.assertEqual(WIDGET_LABEL1, demoWidget3.labelNode.innerHTML);
								runner.assertEqual(WIDGET_LABEL1, demoWidget1.get("label"), 'return value of get("label") should be ' + WIDGET_LABEL1);
								runner.assertEqual(WIDGET_LABEL1, demoWidget2.get("label"), 'return value of get("label") should be ' + WIDGET_LABEL1);
								runner.assertEqual(WIDGET_LABEL1, demoWidget3.get("label"), 'return value of get("label") should be ' + WIDGET_LABEL1);
							}), timeoutInterval);
							return d;
						}
					}
				]);
				runner.run();
			});
		});
	</script>
</head>
<body style="visibility:hidden;">
	<div data-dojo-type="dojox.mobile.Heading" data-dojo-props='label:"Arrow"'>
		<button id="btn1" data-dojo-type="dojox.mobile.ToolBarButton" data-dojo-props='light:false'>MMMM</button>
	</div>
	<div data-dojo-type="dojox.mobile.Heading" data-dojo-props='label:"Arrow"'>
		<button id="btn2" data-dojo-type="dojox.mobile.ToolBarButton" data-dojo-props='light:false, arrow:"left"'>MMMM</button>
	</div>
	<div data-dojo-type="dojox.mobile.Heading" data-dojo-props='label:"Arrow"'>
		<button id="btn3" data-dojo-type="dojox.mobile.ToolBarButton" data-dojo-props='light:false, arrow:"right"'>MMMM</button>
	</div>
</body>
</html>
